-- Mason and LSP configuration
require("mason").setup({
	ui = {
		icons = {
			package_installed = "✓",
			package_pending = "➜",
			package_uninstalled = "✗"
		}
	}
})

require("mason-lspconfig").setup({
	ensure_installed = {
		"vimls",
		"lua_ls",
		"vtsls",
		"pylsp",
		"rust_analyzer",
		-- "gopylsppls",
		"cssls",
		"html",
		"yamlls",
		-- "gdscript"
	},
	automatic_installation = true,
})



-- clangd configuration 
require'lspconfig'.clangd.setup{
	capabilities = {
		offsetEncoding = { "utf-8", "utf-16" },
		textDocument = {
			completion = {
				editsNearCursor = true
			}
		}
	},
	cmd = { "clangd" },
	filetypes = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
	root_dir = require'lspconfig'.util.root_pattern("compile_commands.json", ".git"),
	single_file_support = true,
}

local lspconfig = require('lspconfig')

-- C# (OmniSharp) configuration
lspconfig.omnisharp.setup{
	cmd = { "F:\\omnisharp-win-x64-net6.0\\OmniSharp.exe" },
	root_dir = lspconfig.util.root_pattern("*.sln", "*.csproj", ".git"),
	single_file_support = true,
}

lspconfig.lemminx.setup({
	cmd = { 'F:\\lemminx-win32\\lemminx-win32.exe' }, -- 使用绝对路径
	filetypes = { 'xml' },
})

local capabilities = require('cmp_nvim_lsp').default_capabilities()

-- Vimls configuration
require("lspconfig").vimls.setup {
	capabilities = capabilities
}

-- Go LSP configuration
require("lspconfig").gopls.setup {
	capabilities = capabilities
}
-- html LSP
require'lspconfig'.html.setup{
	capabilities = capabilities
}
-- Css Lsp
require'lspconfig'.cssls.setup{
	capabilities = capabilities
}
-- TypeScript
-- require'lspconfig'.ts_ls.setup{
-- 	capabilities = capabilities,
-- 	root_dir = require'lspconfig'.util.root_pattern("tsconfig.json", "jsconfig.json", ".git")
-- }

-- TypeScript
require'lspconfig'.vtsls.setup{
	capabilities = capabilities,
	root_dir = require'lspconfig'.util.root_pattern("tsconfig.json", "jsconfig.json", ".git")
}

-- GDScript
require'lspconfig'.gdscript.setup{
	capabilities = capabilities
}
-- PYthon
require'lspconfig'.pylsp.setup{
	capabilities = capabilities
}
-- Rust
require'lspconfig'.rust_analyzer.setup{
	capabilities = capabilities
}
-- Yaml
require'lspconfig'.yamlls.setup{
	capabilities = capabilities
}
-- vue_ls LSP
require'lspconfig'.vue_ls.setup{
	capabilities = capabilities
}
